package com.lagou.session;

import com.lagou.config.XmlConfigBuilder;
import com.lagou.pojo.Configuration;

import java.io.InputStream;

/**
 * 解析配置数据并创建sqlSessionFactory
 *
 * @author srh
 * @date 2020/02/22
 **/
public class SqlSessionFactoryBuilder {

    private Configuration configuration;

    public SqlSessionFactory build(InputStream in) throws Exception {
        XmlConfigBuilder xmlConfigBuilder = new XmlConfigBuilder();
        configuration = xmlConfigBuilder.parseConfig(in);
        return new DefaultSqlSessionFactory(configuration);
    }

}
